﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Windows.UI.Xaml.Data;

namespace Ch9RSS_Universal.Converters
{
    public class ListLimitConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            IEnumerable<object> sourceList = (IEnumerable<object>)value;
            int limitCount = System.Convert.ToInt32(parameter);
            if (sourceList.Count() > limitCount) { 
                var returnList = sourceList.Take(limitCount);
                return returnList;
            }
            return sourceList;
            
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }
}
